<template>
  <div class="you">
    <div class="find" >
      <!-- 顶部 -->
      <div class="top" :class="color">
        <div class="txt">
          <h3>有了</h3>
        </div>
        <div class="input" @click="ck">
          <p>有哪些常考的面试题</p>
        </div>
        <div class="message"></div>
        <div class="img"></div>
      </div>
      <!-- 图片集 -->
      <div id="icon">
        <!-- 五个小图 -->
        <div class="icon_t">
          <!-- 循环 -->
          <div class="icon_f" id="icon_f" v-for="(item,index) in imgArr" :key="index">
            <div class="img" :style="{backgroundPosition:item.dis}"></div>
            <p>{{item.text}}</p>
          </div>
        </div>
        <!-- 两个矩形 -->
        <div class="icon_b">
          <div class="prize">
            <div class="icon"></div>
            <div class="text">
              <h6>昂扬春招</h6>
              <p>每日奖…</p>
            </div>
          </div>
          <div class="live">
            <div class="icon"></div>
            <div class="text">
              <h6>校招直播</h6>
              <p>正在直播</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 数据渲染 -->
    <div class="data" >
      <!-- 标题 -->
      <div class="title" :style="sty">
        <p>关注</p>
        <h3>推荐</h3>
        <p>问答交流</p>
        <p>好文</p>
      </div>
      <!-- 数据 -->
      <div class="cont">
        <div class="ul">
          <div class="list" v-for="(item,index) in data" :key="index">
            <!-- 头 -->
            <div class="list_t">
              <div class="t_name">
                <div class="t_img" :style="{background:'url('+URL+item.img+'.svg) 0 0/100%'}"></div>
                <div>
                  <p class="name">{{item.name}}</p>
                <p>{{item.job}}</p>
                </div>
              </div>
              <div class="dian">…</div>
            </div>
            <!-- 问 -->
            <div class="ask">
              <span>问</span>
              <p>{{item.title}}</p>
            </div>
            <!-- 答 -->
            <div class="answer">
              <p v-html="item.text">{{item.text}}</p>
            </div>
            <!-- 评论 点赞-->
            <div class="inter">
              <div class="i1"><span>24</span></div>
              <div class="i2"><span>5</span></div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- <Search v-show="!flg"></Search> -->
  </div>
</template>
<script>
import Search from '@/components/Search.vue'
export default {
  components:{
    Search
  },
  data(){
    return {
      imgArr:[
        {text:"今日热榜",dis:"5px 3px"},
        {text:"学生圈",dis:"-23px 4px"},
        {text:"求职冒险",dis:"-50px 4px"},
        {text:"职业百科",dis:"-77px 4px"},
        {text:"找公司",dis:"-105px 4px"},
      ],
      data:[],
      sty:null,
      color:'',
    }
  },
  mounted(){
    window.addEventListener("scroll",this.scrollTop)
    this.color = this.$store.getters.color
  },
  computed:{
  },
  methods:{
    scrollTop(){
      let top = window.pageYOffset
      // console.log(top);
      if(top>158){
        this.sty = {position:"fixed",top:"66px"}
      }else {
        this.sty =null
      }
    },
    ck(){
      this.$router.push('/search')
      this.$store.commit('judge')
    }
    // ent(text){
    //   let subStr=/<br \/>/ig;
    //   let result=text.replace(subStr,"");
    //   return result
    // }
  },
  
  created(){
    this.data = this.$store.getters.data.share
    // console.log(this.data);
  }
}
</script>
<style scoped lang="scss">
  .you{
    width: 100vw;
    background: #F5F6F5;
    .find {
      // 顶部
      .top {
        width: 100%;
        height: 18vw;
        // background: #35C2BB;
        color: #fff;
        padding: 0 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        z-index: 999;
        .txt {
          font-size: 18px;
          font-family: 'Courier New', Courier, monospace;
        }
        .input {
          width: 50vw;
          background: rgba(255, 255, 255, .3);
          border-radius: 20px;
          padding: 7px 15px;
          p {
            margin-left: 22px;
            font-size: 12px;
            opacity: .9;
            position: relative;
          }
          p::before{
            content: '';
            display: inline-block;
            width: 20px;
            height: 20px;
            position: absolute;
            top: 1px;
            left: -22px;
            background: url(#{$URL}search.svg) no-repeat;
            background-size: 70%;
          }
        }
        .message {
          width: 25px;
          height: 25px;
          background: url(#{$URL}notice.png) no-repeat;
          background-size: 100%;
        }
        .img {
          width: 25px;
          height: 25px;
          background: url(#{$URL}01.svg) no-repeat;
          background-size: 100%;
        }
      }
      // 图片层
      #icon {
        margin-top: 18vw;
        padding: 20px 20px 15px;
        background: #fff;
        .icon_t{
          display: flex;
          justify-content: space-between;
          font-size: 12px;
          color: #767678;
          .icon_f{
            .img {
              width: 27px;
              height: 29px;
              margin: 0 auto 3px;
              background-image: url(#{$URL}you/you.png);
              background-size: 480%;
              background-repeat: no-repeat;
            }
          }
          #icon_f div:nth-child(3){
            width: 28px;
          }
        }
        // 两个矩形 
        .icon_b {
          margin: 15px auto 0;
          display: flex;
          justify-content: space-between;
          align-items: center;
          // 左边盒子
          .prize {
            width: 40vw;
            display: flex;
            justify-content: space-around;
            align-items: center;
            padding: 10px 10px;
            background: #F1FBF9;
            border-radius: 8px;
            .icon {
              width: 25px;
              height: 25px;
              background: url(#{$URL}/you/you.png) 0px -25px /500%;
            }
            .text {
              font-size: 12px;
              // transform: scale(1);
            }
          }
          // 右边盒子
          .live {
            width: 40vw;
            display: flex;
            justify-content: space-around;
            align-items: center;
            padding: 10px 10px;
            background: #EEF9FF;
            border-radius: 8px;
            .icon {
              width: 25px;
              height: 20px;
              background: url(#{$URL}/you/you.png) -25px -20px /420%;
            }
            .text {
              font-size: 12px;
              // transform: scale(.8);
            }
          }
        }
      }
    }
    // 数据盒子
    .data {
      width: 100%;
      margin-top: 7px;
      // padding: 0 20px;
      // background: #fff;
      // 标题
      .title {
        width: 100%;
        background: #fff;
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 10px;
        border-bottom: 1px solid #eeeeee;
        // background: #fff;
        p {
          font-size: 14px;
          color: #848484;
          
        }
        h3 {
          position: relative;
        }
        h3::before {
          content: '';
          display: inline-block;
          width: 15px;
          height: 4px;
          border-radius: 8px;
          background: #59C3BB;
          position: absolute;
          top: 26px;
          left: 10px;
        }
      }
      // 数据
      .cont {
        width: 100%;
        // padding: 20px;
        .ul{
          width: 100%;
          .list {
            width: 100%;
            padding: 20px 20px;
            margin-bottom: 10px;
            background: #fff;
            // 头
            .list_t {
              // width: 100%;
              display: flex;
              justify-content: space-between;
              .t_name {
                flex: 2;
                display: flex;
                .t_img {
                  width: 30px;
                  height: 30px;
                  margin-right: 10px;
                  border-radius: 50%;
                  // background: #35C2BB;
                  display: inline-block;
                }
                p{
                  font-size: 12px;
                  color: #9B9B9A;
                }
                .name {
                  font-weight: bold;
                  color: #000;
                }
              }
              .dian {
                font-size: 18px;
                color: #9B9B9A;
              }
            }
            // 问
            .ask{
              margin-top: 10px;
              font-size: 14px;
              font-weight: bold;
              // padding: 1%;
              display: flex;
              span{
                margin-right: 8px;
                display: block;
                width: 17px;
                height: 17px;
                font-size: 12px;
                color: #35C2BB;
                border: 1px solid #35C2BB;
                padding: 0px 1.5px;
                border-radius: 2px;
              }
            }
            // 答
            .answer{
              height: 100px;
              // border: 1px solid red;
              overflow: hidden;
              p {
                width: 100%;
                font: 14px/218% "";
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
              }
            }
            // 评论点赞
            .inter {
              display: flex;
              div {
                width: 20px;
                height: 20px;
                // padding-left: 20px;
                margin-right: 50px;
                span {
                  margin-left: 30px;
                }
              }
              .i1 {
                background: url(#{$URL}/you/praise.svg) 0 0/100%;
                span {
                  line-height: 22px;
                }
              }
              .i2 {
                background: url(#{$URL}/you/comment.svg) 0 0/100%;
                span {
                  line-height: 20px;
                }
              }
            }
          }
        }
      }
    }
  }
</style>